//
//  GoodStoreDetailCollectionViewCell.m
//  礼物
//
//  Created by dllo on 15/11/12.
//  Copyright © 2015年 liangsicheng. All rights reserved.
//

#import "GoodStoreDetailCollectionViewCell.h"

@implementation GoodStoreDetailCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        [self creataSubviews];
    }
    return  self;
}

- (void)creataSubviews
{
    
    self.contentView.backgroundColor = [UIColor whiteColor];
    //图片
    self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height / 3 * 2)];
    //self.imageView.backgroundColor = [UIColor cyanColor];
    [self.contentView addSubview:self.imageView];
    
    //名字
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, self.imageView.frame.size.height, self.imageView.frame.size.width, self.contentView.frame.size.height / 3 / 3 * 2)];
    //self.nameLabel.backgroundColor = [UIColor orangeColor];
    [self.contentView addSubview:self.nameLabel];
    
    //价钱
    self.priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, self.imageView.frame.size.height + self.nameLabel.frame.size.height, self.nameLabel.frame.size.width / 2, self.contentView.frame.size.height - self.imageView.frame.size.height - self.nameLabel.frame.size.height)];
    //self.priceLabel.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:self.priceLabel];
    
    //爱心
    self.heartImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.priceLabel.frame.size.width, self.priceLabel.frame.origin.y, self.priceLabel.frame.size.height, self.priceLabel.frame.size.height)];
    self.heartImageView.image = [[UIImage imageNamed:@"21"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];//取消渲染
    //self.heartImageView.backgroundColor = [UIColor blackColor];
    [self.contentView addSubview:self.heartImageView];
    
    //喜欢
    self.likeLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.heartImageView.frame.origin.x + self.heartImageView.frame.size.width + 3, self.heartImageView.frame.origin.y, self.contentView.frame.size.width - self.priceLabel.frame.size.width - self.heartImageView.frame.size.width - 3, self.heartImageView.frame.size.height)];
    //self.likeLabel.backgroundColor = [UIColor greenColor];
    [self.contentView addSubview:self.likeLabel];
}

-(void)setGoodStoreDetailModel:(RecommenModel *)goodStoreDetailModel
{
           _goodStoreDetailModel = goodStoreDetailModel;
    
    
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:_goodStoreDetailModel.cover_image_url]];
    
    self.nameLabel.text = _goodStoreDetailModel.name;
    self.nameLabel.textAlignment = NSTextAlignmentLeft;
    self.nameLabel.lineBreakMode = NSLineBreakByWordWrapping;
    self.nameLabel.numberOfLines = 0;
    //[self.nameLabel sizeToFit];
    self.nameLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:19];
    
    self.priceLabel.text = _goodStoreDetailModel.price;
    self.priceLabel.textAlignment = NSTextAlignmentCenter;
    self.priceLabel.textColor = [UIColor redColor];
    self.priceLabel.font = [UIFont systemFontOfSize:15];
    
    self.likeLabel.text = [NSString stringWithFormat:@"%ld",_goodStoreDetailModel.favorites_count];
    self.likeLabel.textColor = [UIColor lightGrayColor];
    
    
    
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
